export const getResponseBody = (xhr: XMLHttpRequest): any => {
	if (xhr.status !== 204) {
		try {
			const contentType = xhr.getResponseHeader('Content-Type');
			if (contentType) {
				const jsonTypes = ['application/json', 'application/problem+json']
				const isJSON = jsonTypes.some(type => contentType.toLowerCase().startsWith(type));
				if (isJSON) {
					return JSON.parse(xhr.responseText);
				} else {
					return xhr.responseText;
				}
			}
		} catch (error) {
			console.error(error);
		}
	}
	return undefined;
};
